<?php



class VsOrderStatus {

	static private $AvailableStatuses = array();

	private $_key = NULL;
	private $_value = NULL;

	function __construct($key=1) {
		//echo sizeof(self::$AvailableStatuses);
		//exit;

		if(!sizeof(self::$AvailableStatuses))
			self::initAvailableStatuses();

		$this->_key = $key;
		$this->_value = self::$AvailableStatuses[$key];
	}
	//==========================================================================

	function key() { return $this->_key; }
	function value() { return $this->_value; }

	function setStatus($status) {
		//print_r(self::$AvailableStatuses);
		//exit;

		if(!isset(self::$AvailableStatuses[$status]))
			return FALSE;

		$this->_key = $status;
		$this->_value = self::$AvailableStatuses[$status];
		
		//echo $this->_value;
		//exit;
		
		return TRUE;
	}
	//===========================================================================

	static function AvailableStatuses() { return self::$AvailableStatuses; }

	static private function initAvailableStatuses() {
		$db = VsDatabase::Instance();
		$q = "SELECT * FROM `order_statuses`";
		$res = $db->query($q);
		while($status = mysql_fetch_assoc($res)) {
			self::$AvailableStatuses[$status['key']] = $status['value_en'];
		
			//echo $status['value_en'];
			//exit;
		}

	}
	//=========================================================================

};

?>
